Other process P2 wants to enter its critical section while P1 is in its critical section, it uses the shared semaphore value 0 and performs wait operation first.
2.
To overcome the need for busy waiting, we can modify the definition of wait and signal semaphore operations . When a process executes the wait operation and finds that the semaphore value is not > 0, it is entered into waiting queue associated with the semaphore and the state of the process is switched to the waiting state.